#coding:utf8
#验证括号配对的正确性，
#栈的应用
class Solution(object):
    def isValid(self,s):
        dict = {"}":"{","]":"[",")":"("}
        stack = []
        for st in s:
            if st in dict.values():
                stack.append(st)
            elif len(stack)>0:
                p = stack.pop()
                if p != dict[st]:
                    return False
            else:
                return False
        return stack == []

        
